package UI;

import java.util.Vector;

import data_management.InvDBManager;
import data_management.Main;
import data_management.PermissionManager;
import junit.framework.TestCase;

public class InventoryInterfaceTest extends TestCase {

	/*************************************************************************
	 * This method tests the inititalize() method of the InventoryInterface Class
	 *************************************************************************/
	public void testinitialize(){
		
		InvDBManager.getInstance().initializeDatabase();
		new Main();
		
		InventoryInterface.getInstance().initialize();
	}
	
	/*****************************************************************************************
	 * This method tests the addCategory() method of the InventoryInterface Class for an admin
	 *****************************************************************************************/
	public void testaddCategoryadmin(){
		
		int i;
		boolean good = false;
		
		PermissionManager.getInstance().loginUser("j", "j");
		
		InventoryInterface.getInstance().addCategory("randomcategory");
		Vector<String> columns = InvDBManager.getInstance().getColumns("inventory");
		
		for(i = 0; i < columns.size();i++){
			
			if(columns.get(i).equals("randomcategory")){
				good = true;
			}
			
		}
		assertTrue(good = true);
		
	}
	
	/****************************************************************************************
	 * This method tests the addCategory() method of the InventoryInterface Class for a clerk
	 ****************************************************************************************/
	public void testaddCategoryclerk(){
		
		int i;
		boolean good = false;
		
		PermissionManager.getInstance().loginUser("ck", "shene");
		
		InventoryInterface.getInstance().addCategory("othercategory");
		Vector<String> columns = InvDBManager.getInstance().getColumns("inventory");
		
		for(i = 0; i < columns.size();i++){
			
			if(columns.get(i).equals("othercategory")){
				good = true;
			}
			
		}
		assertTrue(good == false);
		
	}
	
	
	
	
	
}
